<style>
    /* 公共样式 */
    image {
        display: block;
    }

    .u-user-pic-wrap {
        display: flex;
        justify-content: center;
        align-items: center;
        background: #f5f5f5;
        border-radius: 100rpx;
        overflow: hidden;
    }

    .u-user-pic-wrap image {
        width: 100%;
		height: 100%;
    }

    .g-page {
        font-size: 28upx;
        overflow-x: hidden;
        background: #fafafa;
        padding-bottom: 40upx;
        min-height: 100vh;
    }

    /* 页眉 */
    .g-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 10;
        height: 88upx;
        line-height: 88upx;
        color: rgba(0, 0, 0, 0);
        text-align: center;
        background: rgba(255, 255, 255, 0);
        transition: .5s;
    }

    .u-header-pic {
        width: 40upx;
        height: 40upx;
        position: absolute;
        left: 40upx;
        bottom: 24upx;
        opacity: 0;
        transition: .5s;
    }

    .g-header-qr {
        width: 40upx;
        position: absolute;
        right: 100upx;
        bottom: 24upx;
    }

    .g-header-qr image {
        width: 85%;
    }

    .u-header-setting {
        width: 40upx;
        position: absolute;
        right: 30upx;
        bottom: 24upx;
    }

    .scroll .u-header-pic {
        opacity: 1;
    }

    .g-header.scroll {
        background: rgba(255, 255, 255, .9);
        color: rgba(0, 0, 0, 1);
    }

    /* 个人信息 */
    .g-user-info-wrap {
        position: relative;
        height: 400upx;
    }

    .u-user-bg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 2;
    }

    .g-user-info {
        width: 100%;
        display: flex;
        align-items: center;
        position: absolute;
        z-index: 9;
        top: 150upx;
        left: 30upx;
        color: #fff;
        font-size: 32upx;
    }

    .u-user-pic {
        width: 130upx;
        height: 130upx;
        margin-right: 20upx;
    }

    .weixin-sign {
        width: 36upx;
        margin-left: 10upx;
    }

    .g-assets {
        width: 100%;
        display: flex;
        text-align: center;
        align-items: flex-end;
        padding: 20upx;
        box-sizing: border-box;
        background: #fff;
        transform: translateY(-60%);
        position: relative;
        z-index: 0;
        height: 160upx;
    }

    .g-assets-item {
        flex: 1;
    }

    .u-assets-field {
        display: block;
        font-size: 32upx;
        color: #3b3b3b;
        margin-bottom: 20upx;
    }

    .u-assets-number {
        display: block;
        font-size: 28upx;
        color: #828080;
    }

    /* 按钮导航 */
    .m-nav {
        width: 100%;
        background: #fff;
        margin-top: 32upx;
        box-sizing: border-box;
        position: relative;
    }

    .u-nav-title {
        font-size: 32upx;
        text-indent: 38upx;
        position: relative;
        padding: 10px 15px;
    }

    .u-nav-title::after {
        content: '';
        display: block;
        width: 8upx;
        height: 32upx;
        background: #df4543;
        position: absolute;
        top: 50%;
        left: 38upx;
		margin-top: -16upx;
    }

    
	.nav-list{
		display: flex;
		align-items: flex-start;
		flex-wrap: wrap;
		align-items: flex-start;
	}
	.nav-list .g-nav-item{
		width: 33.33%;
		position: relative;
		text-align: center;
		padding: 30upx 0;
	}
	.nav-list .g-nav-item .icon{
		width: 70upx;
		margin: 0 auto;
		position: relative;
	}
	.nav-list .g-nav-item image{
		width: 70upx;
		height: 50upx;
		margin: 0 auto;
		margin-bottom: 10upx;
	}
    .u-msg-dot {
        position: absolute;
        top: -4upx;
        right: -4upx;
    }


    /* 弹框 */
    .popup-qr {
        position: fixed;
        top: 50%;
        left: 50%;
        z-index: 9;
        transform: translate(-50%, -50%);
        width: 90%;
    }

    .popup-bg {
        width: 100%;
        height: 756upx;
    }

    .popup-user {
        width: 150upx;
        height: 150upx;
        border-radius: 100px;
        position: absolute;
		z-index: 10;
        top: 16upx;
        left: 50%;
        transform: translate(-51%, 0%);
    }

    .popup-name {
        position: absolute;
        top: 184upx;
        left: 50%;
        font-size: 32upx;
        transform: translateX(-55%);
        color: #ffe611;
    }

    .qr-img {
        position: absolute;
        left: 50%;
        bottom: 150upx;
        width: 320upx;
        height: 320upx;
        transform: translateX(-50%);
        background: #fff;
        padding: 20upx;
    }

    .g-popup-mask {
        position: fixed;
        top: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, .5);
        z-index: 10;
    }

    .g-close {
        position: absolute;
        bottom: -100upx;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        justify-content: center;
        align-items: center;
        border: 3px solid #fff;
        border-radius: 100px;
        padding: 10upx;
    }
	.popup-text{
		color: #ffffff;
		font-size: 30upx;
		letter-spacing: 2upx;
		width: 100%;
		text-align: center;
		position: absolute;
		bottom: 50upx;
		left: 0;
	}
</style>

<template>
    <view class="g-page">
        <!-- 个人信息 -->
        <view class="g-user-info-wrap">
            <view class="g-user-info" @tap="toLogin">
                <view class="u-user-pic u-user-pic-wrap">
                    <image :src="data.head_pic_text" mode="widthFix"></image>
                </view>
				<view class="user-info">
					<text>{{data.realname?data.realname:data.nickname}}</text>
					<view v-if="isLogin">
						<view v-if="isLogin">
							<text v-if="data.member_id">ID:{{data.member_id}}</text>
							<text v-if="data.user_id!='' && data.user_id != data.member_id">({{data.user_id}})</text>
						</view>
						<view>{{data.mobile}}</view>
					</view>
				</view>
                <image class="weixin-sign" src="../../static/icons/weixin2.png" mode="widthFix" v-if="nIsBingWeixin"></image>
            </view>
            <image class="u-user-bg" src="../../static/images/user_bg.png" mode="widthFix"></image>
        </view>
        <view class="g-assets">
            <view class="g-assets-item" @tap="toStore('lc')">
                <text class="u-assets-field">粮仓</text>
                <text class="u-assets-number">{{data.all_money||0}}</text>
            </view>
			<!-- <view class="g-assets-item" @tap="toStore('new')">
			    <text class="u-assets-field">新粮仓</text>
			    <text class="u-assets-number">{{data.all_money||0}}</text>
			</view> -->
        </view>

        <!-- 按钮导航 -->
        <view class="m-nav" style="margin-top: -60upx;">
			<view v-if="isGoodsTpye">
				<view class="u-nav-title">我的拼团</view>
				<view class="nav-list">
					<navigator open-type="navigate" class="g-nav-item" url="/pages/user/grouping">
						<view class="icon">
							<image src="../../static/icons/user_nav18.png" mode="widthFix"></image>
							<view class="u-msg-dot" v-if="grouping_dot"></view>
						</view>
						<text>成团中</text>
					</navigator>
					<navigator open-type="navigate" class="g-nav-item" url="/pages/user/grouped">
						<view class="icon">
							<view class="u-msg-dot" v-if="grouped_dot"></view>
							<image src="../../static/icons/user_nav4.png" mode="widthFix"></image>
						</view>
						<text>已成团</text>
					</navigator>
					<navigator open-type="navigate" class="g-nav-item" url="/pages/user/group_finish">
						<image src="../../static/icons/user_nav19.png" mode="widthFix"></image>
						<text>已完成</text>
					</navigator>
					<navigator open-type="navigate" class="g-nav-item" url="/pages/order/orderlist">
						<image src="../../static/icons/user_nav7.png" mode="widthFix"></image>
						<text>拼团发货</text>
					</navigator>
					<navigator open-type="navigate" class="g-nav-item" url="/pages/pawn/order">
						<image src="../../static/icons/pawn_order.png" mode="widthFix"></image>
						<text>订货发货</text>
					</navigator>
					<navigator open-type="navigate" class="g-nav-item" url="/pages/pawn/allowance">
						<image src="../../static/icons/pawn_allowance.png" mode="widthFix"></image>
						<text>订货津贴</text>
					</navigator>
				</view>
			</view>
			<view v-if="!isGoodsTpye">
				<view class="u-nav-title">我的订单</view>
				<view class="nav-list">
					<navigator open-type="navigate" class="g-nav-item" url="/pages/user/grouping">
						<view class="icon">
							<image src="../../static/icons/user_nav18.png" mode="widthFix"></image>
							<view class="u-msg-dot" v-if="grouping_dot"></view>
						</view>
						<text>待发货</text>
					</navigator>
					<navigator open-type="navigate" class="g-nav-item" url="/pages/user/grouped">
						<view class="icon">
							<view class="u-msg-dot" v-if="grouped_dot"></view>
							<image src="../../static/icons/user_nav4.png" mode="widthFix"></image>
						</view>
						<text>待收货</text>
					</navigator>
					<navigator open-type="navigate" class="g-nav-item" url="/pages/user/group_finish">
						<image src="../../static/icons/user_nav19.png" mode="widthFix"></image>
						<text>已完成</text>
					</navigator>
				</view>
			</view>
        </view>
        <view class="m-nav" v-if="isGoodsTpye">
            <view class="u-nav-title">二手寄售</view>
        	<view class="nav-list">
        		<navigator open-type="navigate" class="g-nav-item" url="/pages/transfer/buyer_list?pageType=1">
        			<image src="../../static/icons/buyd.png" mode="widthFix"></image>
        			<text>我买到的</text>
        		</navigator>
        		<navigator open-type="navigate" class="g-nav-item" url="/pages/transfer/buyer_list?pageType=2">
        			<image src="../../static/icons/saled.png" mode="widthFix"></image>
        			<text>我卖出的</text>
        		</navigator>
				<navigator open-type="navigate" class="g-nav-item" url="/pages/transfer/publish_list">
					<image src="../../static/icons/publish.png" mode="widthFix"></image>
					<text>我的发布</text>
				</navigator>
        	</view>
        </view>
		<view class="m-nav">
            <view class="u-nav-title">恒朗服务</view>
			<view class="nav-list">
				<navigator open-type="navigate" class="g-nav-item" url="/pages/user/notice">
					<image src="../../static/icons/user_nav1.png" mode="widthFix"></image>
					<text>系统通知</text>
				</navigator>
				<navigator open-type="navigate" class="g-nav-item" v-if="isGoodsTpye" url="/pages/Loan/Loan_list">
					<image src="../../static/icons/user_nav22.png" mode="widthFix"></image>
					<text>我的质押</text>
				</navigator>
				<navigator open-type="navigate" class="g-nav-item" v-if="isGoodsTpye" url="/pages/user/hlb_confluence">
					<image src="../../static/icons/user_nav8.png" mode="widthFix"></image>
					<text>恒朗总汇</text>
				</navigator>
				<navigator open-type="navigate" class="g-nav-item" v-if="isLogin&isGoodsTpye" url="/pages/user/team">
					<image src="../../static/icons/user_nav17.png" mode="widthFix"></image>
					<text>乐购好友</text>
				</navigator>
				<navigator open-type="navigate" class="g-nav-item" v-if="isLogin&isGoodsTpye&isAgent" url="/pages/user/agent_index">
					<image src="../../static/icons/user_nav5.png" mode="widthFix"></image>
					<text>代理点统计</text>
				</navigator>
				<navigator open-type="navigate" class="g-nav-item" v-if="isGoodsTpye" url="/pages/user/video">
					<image src="../../static/icons/user_nav3.png" mode="widthFix"></image>
					<text>视频教学</text>
				</navigator>
				<!-- <view class="g-nav-item" v-if="isGoodsTpye" @tap="goApp('shop')">
					<image src="../../static/icons/user_nav21.png" mode="widthFix"></image>
					<text>积分商城</text>
				</view> -->
				<navigator open-type="navigate" class="g-nav-item" v-if="isGoodsTpye" url="/pages/user/operate_tips">
					<image src="../../static/icons/user_nav6.png" mode="widthFix"></image>
					<text>帮助中心</text>
				</navigator>
			</view>
        </view>
        <!-- 二维码弹框 -->
        <view class="g-popup-mask" v-if="bIsPopup">
            <view class="popup-qr">
                <image class="popup-user" :src="data.head_pic_text"></image>
                <text class="popup-name">{{data.nickname}}</text>
                <image class="popup-bg" src="../../static/images/user/qr_bg.png" mode="widthFix"></image>
                <image class="qr-img" :src="data.qrcode"></image>
				<view class="popup-text">
					<view>扫一扫上面的二维码图案，参与优惠购物</view>
				</view>
                <view class="g-close" @tap="togglePopup">
                    <close size="40" color="#fff"></close>
                </view>
            </view>
        </view>
    </view><!-- g-page -->

</template>
<script>
	import henglang from '@/common/common.js';
    export default {
        data() {
            return {
                data: {
                    nickname: '点击登录',
                    head_pic_text: '../../static/images/no_login.png',
                },
                nIsLogin: false,
                nIsScroll: false,
                nIsBingWeixin: false,
                bIsPopup: false,
                bIsShowLoading: false,
                grouping_dot: false, // 显示红点
				grouped_dot: false, // 显示红点
                isLogin: false,
				StoreUrl:'',
				isAgent:false,
				isGoodsTpye: uni.getStorageSync('isGoodType'),
				onLoadData:{}
            };
        },
        methods: {
            toLogin() {
                if (!this.isLogin) {
					uni.navigateTo({
						url: '/pages/user/login'
					}) 
                }else{
					uni.navigateTo({
						url: '/pages/user/settings/set_index'
					}) 
				}
            },
            togglePopup() {
                this.bIsPopup = !this.bIsPopup;
            },
			toStore(e) {
				if (this.isLogin && this.isGoodsTpye) {
					if(e == 'lc'){
						uni.navigateTo({
							url:'/pages/user/confluence?type=0'
						})
					}else if(e == 'kd'){
						uni.navigateTo({
							url:'/pages/common/bill?type=2'
						})
					}else if(e == 'allowance'){
						uni.navigateTo({
							url:'/pages/common/bill?type=3'
						})
					}/* else if(e == 'new'){
						uni.navigateTo({
							url:'/pages/user/new_deital'
						})
					} */
					
				}
			},
			goApp(type){
				let data = {}
				switch(type){
					case 'rice':
						data = {
							'pname': 'com.m420899440.zkz',
							'action': 'iosmobhenglangcom://index.html',
							'download_url':'http://a.app.qq.com/o/simple.jsp?pkgname=com.m420899440.zkz'
						}
					break;
					case 'shop':
						data = {
							'pname': 'com.m420899440.zkz',
							'action': 'iosmobhenglangcom://',
							'download_url':'http://a.app.qq.com/o/simple.jsp?pkgname=com.m420899440.zkz'
						}
					break;
				}
				henglang.launchApp(data,plus);
			},
			back() {
				if(this.onLoadData.type == 'ydt'){
					uni.navigateBack()
				}else{
					uni.switchTab({
						url:'/pages/jewel/user/user'
					})
				}
			}
        },
        onPageScroll({
            scrollTop
        }) {
            if (scrollTop > 50) {
                this.nIsScroll = true;
            } else {
                this.nIsScroll = false;
            }
        },
		onLoad(options) {
			this.onLoadData = options
			// console.log(this.isGoodsTpye)
		},
        onShow() {
            let that = this;
            that.isLogin = henglang.checkLogin();
            if (that.isLogin) {
                henglang.get('member/getInfo',{},true,function(res){
					if(res.data.code == '0'){
						that.data = res.data.data;
						if(that.data.is_agent == 1){
							that.isAgent = true
						}
						uni.setStorage({
							key: 'userInfo',
							data: res.data.data
						});
					}else{
						uni.setStorage({
							key: 'userInfo',
							data: ''
						});
						uni.setStorage({
							key: 'token',
							data: ''
						});
						this.isLogin = false
					}
				});
                // 查看成团中
				henglang.get('order/getTeamLoading',that.sendData,true,function(res){
					if (res.data.data.length) {
						that.grouping_dot = true;
					}else{
						that.grouping_dot = false;
					}
				});
				// 查看已成团
				henglang.get('order/getHasTeam',that.sendData,true,function(res){
					if (res.data.data.length) {
						that.grouped_dot = true;
					}else{
						that.grouped_dot = false;
					}
				});
            }else{
				that.grouped_dot = false;
				that.grouping_dot = false;
				that.data = {
				    nickname: '点击登录',
				    head_pic_text: '../../static/images/no_login.png',
				}
			}
        },
        onNavigationBarButtonTap(e) {
            let that = this;
            if (e.index === 0) {
                uni.navigateTo({
                    url: '/pages/user/settings/set_index'
                })
            } else if (e.index === 1) {
                if (this.isLogin) {
					henglang.get('member/myQrCode',{},true,function(res){
						that.data.qrcode = res.data.data;
					});
                    this.bIsPopup = !this.bIsPopup;
                } else {
                    henglang.showToast('请先登录',1000);
                }
            }
        },
        onPullDownRefresh() {
            let that = this;
            if (!this.isLogin) {
                henglang.showToast('请先登录',1000);
                uni.stopPullDownRefresh();
            } else {
                new Promise((resolve, reject) => {
					henglang.post('member/getInfo',{},true,function(res){
						if(res.data.code == '0'){
							that.data = res.data.data;
							uni.setStorage({
								key: 'userInfo',
								data: res.data.data
							});
						}else{
							uni.setStorage({
								key: 'userInfo',
								data: ''
							});
							uni.setStorage({
								key: 'token',
								data: ''
							});
							this.isLogin = false
						}
						resolve();
					});
                }).then(() => {
                    // 查看成团中
					henglang.get('order/getTeamLoading',that.sendData,true,function(res){
						if (res.data.data.length) {
							that.grouping_dot = true;
						} else {
							that.grouping_dot = false;
						}
					});
                    // 查看成团中
					henglang.get('order/getHasTeam',that.sendData,true,function(res){
						if (res.data.data.length) {
							that.grouped_dot = true;
						} else {
							that.grouped_dot = false;
						}
					});
					uni.stopPullDownRefresh();
                })
            }
        },
		onBackPress(options) {
		    if (options.from === 'navigateBack') {  
		        return false;  
		    }  
		    this.back();  
		    return true;  
			
		}
    }
</script>